package com.lh.如何防止重复提交表单;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Random;

/**
 * 作者：idea
 * 日期：2018/7/16
 * 描述：
 */
@WebServlet(name = "/upload",urlPatterns = "/upload")
public class UploadPageVister extends HttpServlet {


    char chararr[]={'a','b','c','d','e','f','g','h','j','k','x','e','r'};

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("this is upload");
        System.out.println("--------------");
        HttpSession session=req.getSession();
        Random random=new Random();
        StringBuffer stb=new StringBuffer();
        for(int i=0;i<4;i++) {
           char item=chararr[random.nextInt(chararr.length - 1)];
           stb.append(item);
        }
        session.setAttribute("token",stb.toString());
        resp.sendRedirect("/jsp/upload.jsp");

    }
}
